/*
xp_adc.h
offer adc port function api and data
designed by lunanting

-------------------------
2022-01-10 13:10:47
create file
*/
#include "base_type.h"


/**********************使用说明************************
1. 初始化
2. 配置换算接口，非必须，使用原始数据就不需要；使用换算接口，数据保存在ADC_data.data中
3. 获取接口或者数据对象
******************************************************/

/***********************adc date type******************/
//adc channel
typedef enum{
    adc_channel_0=0,
    adc_channel_1,
    adc_channel_2,
    adc_channel_3,
    adc_channel_4,
    adc_channel_5,
    adc_channel_6,
    adc_channel_7,
    adc_channel_8,
    adc_channel_all,
}ADC_channel;


//adc value
typedef struct{
    u32 value;  //adc origin value
    float  (*value_convert)(u32);  //adc app convert api
    float data;     //app data with unit  converted

}ADC_data;


//adc class
typedef struct{
    int init;   //init status,1=inited
    int num;    //adc channel number
    ADC_data data;  //adc data

}ADC;




/******************************extern api************************/
extern int xp_adc_init(int num);    //init adc module
extern int xp_adc_regist_api(ADC_channel channel,float (*api)(u32));    //regist convert api
extern ADC_data *xp_adc_data_get(ADC_channel channel);  //get adc data



//end of the file
